﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class AudioManager : Singleton<AudioManager>
{
    override public void Init()
    {
        base.Init();
    }
    public void PlayBGM(AudioSource source, AudioClip clip)
    {
        if (source!=null)
        {
            source.clip = clip;
            source.loop = true;
            source.Play();
        }
    }
    public void PlaySFX(AudioSource source, AudioClip clip)
    {
         if (source!=null)
        {
            source.PlayOneShot(clip);
        }
    }
    public void ResumeBGM(AudioSource source, AudioClip clip = null)
    {
        if (source != null)
        {
            if (source.clip != null)
            {
                source.Play();
            }
            else if (clip != null)
            {
                source.clip = clip;
                source.Play();
            }
        }
    }
    public void StopBGM(AudioSource source)
    {
        if (source.isPlaying)
        {
            source.Stop();
        }
    }
    public void StopSFX(AudioSource source)
    {
        if (source.isPlaying)
        {
            source.Stop();
        }
    }
}
